package cc.bookcloud.tool.ocr.codegeex;

import java.util.ArrayList;
import java.util.List;

public class TestCodeGeeX2 {

    public static void main(String[] args) {

        // 定义一个List<UserInfo>类型的变量users
        List<UserInfo> users = new ArrayList<>();
        // 向users中添加5个UserInfo对象
        for (int i = 0; i < 5; i++) {
            users.add(new UserInfo("user" + i, i+10, "user" + i + "@example.com"));
        }
        // 遍历users，输出每个UserInfo对象的username和email
        for (UserInfo user : users) {
            System.out.println("Username: " + user.getUsername() + ", age: " + user.getAge());

        }
        System.out.println("========================================");
        // users按照用户的年龄从大到小进行排序
        users.sort((u1, u2) -> u2.getAge() - u1.getAge());
        // 遍历users，输出每个UserInfo对象的username和email
        for (UserInfo user : users) {
            System.out.println("Username: " + user.getUsername() + ", age: " + user.getAge());
        }


    }
}
